package com.friendview;

import java.io.*;
import java.net.*;
import java.util.*;

import android.app.*;
import android.content.*;
import android.graphics.*;
import android.os.*;
import android.view.*;
import android.widget.*;

import com.formen.ndk.*;

public class FriendArrayAdapter extends ArrayAdapter<String> {
	private final Context context;
	private final String[] values;
	private final String[] statusMsg;
	ImageView imageView;

	public FriendArrayAdapter(Context context, String[] values,
			String[] statusMsg) {
		super(context, R.layout.sns_list, values);
		this.context = context;
		this.values = values;
		this.statusMsg = statusMsg;
	}

	@Override
	public View getView(final int position, View convertView, ViewGroup parent) {
		LayoutInflater inflater = (LayoutInflater) context
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		View rowView = inflater.inflate(R.layout.friend_list, parent, false);

		TextView textView = (TextView) rowView.findViewById(R.id.lbName);
		TextView textView2 = (TextView) rowView.findViewById(R.id.lbStatus);

		if (position % 2 == 0) {
			rowView.setBackgroundColor(Color.parseColor("#CCCCCC"));
			textView2.setTextColor(Color.parseColor("#006400"));
			textView.setTextColor(Color.parseColor("#006400"));
		} else {
			rowView.setBackgroundColor(Color.parseColor("#008B8B"));
			textView2.setTextColor(Color.WHITE);
			textView.setTextColor(Color.WHITE);
		}

		if (position == 0) {
			rowView.setBackgroundColor(Color.parseColor("#008000"));
			textView.setTextColor(Color.WHITE);
			textView2.setTextColor(Color.WHITE);
		}

		textView.setTextSize(18);
		textView2.setTextSize(18);
		textView.setText(values[position].split("\t")[1]);
		textView2.setText(statusMsg[position]);
		// Change icon based on name
		String s = values[position];

		System.out.println(s);

		imageView = (ImageView) rowView.findViewById(R.id.logo);
		Bitmap imgSrc = MainActivity.bitArr.get(position);
		if(imgSrc != null)	imageView.setImageBitmap(imgSrc);

		// if (s.equals("WindowsMobile")) {
		// imageView.setImageResource(R.drawable.heart_bt1);
		// } else if (s.equals("iOS")) {
		// imageView.setImageResource(R.drawable.heart_bt1);
		// } else if (s.equals("Blackberry")) {
		// imageView.setImageResource(R.drawable.heart_bt1);
		// } else {
		// imageView.setImageResource(R.drawable.heart_bt1);
		// }

		return rowView;
	}
}